package com.copa.l2367;

import java.util.HashSet;
import java.util.Set;

/**
 * @author copa
 * @createDate 2023-03-31 9:12
 * @function set集合法
 */
public class Test1 {

    public int arithmeticTriplets(int[] nums, int diff) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            set.add(num);
        }
        int result = 0;
        for (int num : nums) {
            if (set.contains(num + diff) && set.contains(num + diff * 2)) {
                result++;
            }
        }
        return result;
    }

    public static void main(String[] args) {
        int[] nums = {0,1,4,6,7,10};
        int diff = 3;
        System.out.println(new Test1().arithmeticTriplets(nums, diff));
    }
}
